<%@page import="java.util.ArrayList"%>
<%@page import="com.lyb.bean.GaoJian"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>我的稿件</title>
<style type="text/css">
.header{
float:right;
font-size:16px;
}

</style>
</head>
<body>
<%
String username = new String(request.getParameter("username").getBytes("ISO-8859-1"),"utf-8");
System.out.print(username+22);%>
<div class="header">欢迎你，<%=username %>&nbsp;&nbsp;<a href="/zaixiantougao/index.jsp">退出登录</a></div>
<ul>

<li><a href="zaixiantougao.jsp?username=<%= username %>">在线投稿</a></li>
<li><a href="wodegaojian.jsp?username=<%= username %>">我的稿件</a></li>
</ul>
<%

try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String url = "jdbc:mysql://localhost:3306/tougaoxitong?useUnicode=true&characterEncoding=UTF-8";
		String user = "root";
		String mysqlpassword = "";
		
		
		Connection conn = DriverManager.getConnection(url,user,mysqlpassword);
		
			
//			查询
			Statement stmt = conn.createStatement();
			String sql = "select * from gaojian where zuozhe='"+username+"'";
			System.out.print(sql);
			ResultSet rs = stmt.executeQuery(sql);
			ArrayList<GaoJian> gaojianList = new ArrayList<GaoJian>();
			while(rs.next()){
				GaoJian gaojian = new GaoJian();
				String title = rs.getString("title");
				String content = rs.getString("content");
				String zhushi = rs.getString("zhushi");
				String type = rs.getString("type");
				String status = rs.getString("status");
				gaojian.setTitle(title);
				gaojian.setContent(content);
				gaojian.setZhushi(zhushi);
				gaojian.setType(type);
				gaojian.setStatus(status);
				gaojianList.add(gaojian);
				
				}
			System.out.print(gaojianList.size());
			for(int i=0;i<gaojianList.size();i++){
				GaoJian gaojian = gaojianList.get(i);
%>
				<ul>
				<li id="li<%=i%>"><a href="javascript:;"><%=gaojian.getTitle() %>[<%=gaojian.getType() %>](<%=gaojian.getStatus() %>)</a></li>
				<div id="content<%=i%>"><%=gaojian.getContent() %>
				<hr>
				注释：<%=gaojian.getZhushi() %>
				</div>
				</ul>
				<style type="text/css">

#content<%=i%>{
display:none;
}
</style>
				<script type="text/javascript">
var li<%=i%> = document.getElementById("li<%=i%>");
var content<%=i%> = document.getElementById("content<%=i%>");
console.log(li<%=i%>);
li<%=i%>.addEventListener("click",function(){
	if(content<%=i%>.style.display=="none"){
	content<%=i%>.style.display = "block";
	}else{
content<%=i%>.style.display = "none";}
})
</script>
				<% }
			rs.close();
			stmt.close();
			conn.close();
				%>
			
				
			

</body>



</html>